<?php

defined('SYSPATH') or die('Access error!');

class Controller_Admin_Ajax extends Controller
{

    public function __construct(Request $request)
    {
        parent::__construct($request);
        header('Content-Type', 'application/json');
        if (!Request::$is_ajax)
        {
            $this->request->redirect(Route::get('admin/category')->uri());
            return;
        }
    }

    public function action_sub()
    {
        $id = intval($_POST['id']);
        $category = Model_Category::factory('category');
        echo $category->get_sub_category_option($id);
        exit;
    }

    public function action_category_sub()
    {
        $id = intval($_POST['id']);
        if($id == 0){
            exit;
        }
        $category = Model_Category::factory('category');
        echo $category->get_category_option2($id);
        exit;
    }

    public function action_get_setting_group()
    {
        $setting = Model_Setting::factory('setting');
        Template::instance('admin')->assign('setting_gourp', $setting->get_setting_group());
        Template::instance('admin')->display('setting_add.html');
        exit;
    }

}